
#ifndef FBM320_H
#define FBM320_H

#include "iic.h"

#define FBM320_ADDR  0xD8

#define REG_PART_ID  0x6B
#define REG_FBM320_SOFTRESET 0xE0
#define REG_FBM320_CALIBRATION_START0 0xAA
#define REG_FBM320_CALIBRATION_START1 0xD0
#define REG_FBM320_CALIBRATION_START2 0xF1
#define REG_FBM320_TAKE_MEAS 0xF4
#define REG_FBM320_VERSION 0xA5
#define REG_FBM320_READ_MEAS_REG 0xF6

#define CMD_FBM320_SOFTRESET 0xB6
#define CMD_TEMPE_MEAS  0x2E
#define CMD_PRESS_MEAS  0xF4

void fbm320_init(void);

unsigned char fbm320_read_one_byte(unsigned char reg);

void fbm320_read_bytes(unsigned char reg, int len, unsigned char* data);

void fbm320_read_otp(void);

void fbm320_measure(char what);
void fbm320_calculation(long raw_tempe, 
                        float* real_tempe,
                        long raw_press, 
                        long* real_press);

void fbm320_tempe(void);
void fbm320_press(void);
long long pressure_altitude_conversion(long real_pressure);
#endif